package com.mirabelle.juice.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mirabelle.juice.dao.RecipeDao;
import com.mirabelle.juice.model.Author;
import com.mirabelle.juice.model.Recipe;

@Service("RecipeService")
public class RecipeServiceImpl implements RecipeService, Serializable {
	private static final long serialVersionUID = 1L;
	
	@Autowired
	RecipeDao					recipeDao;
	

	@Override
	public List<Recipe> findAll() {
		return recipeDao.getAll();
	}

	@Override
	public List<Recipe> findRecipeByKeyword(String keyword) {
		return recipeDao.findByKeyWord(keyword);
	}
	
	@Override
	public List<Recipe> findRecipeByAuthor(Author author) {
		return recipeDao.findByAuthor(author);
	}
	
	@Override
	public List<Recipe> findRecentRecipe() {
		return findAll();
	}
	
	@Override
	public List<Recipe> findRandomRecipe() {
		List<Recipe> ordered = recipeDao.getAll();
		return ordered;
	}
	
	@Override 
	public void saveRecipe(Recipe recipe) {
		recipeDao.save(recipe);
	}

}
